#ifndef _HDR_TEXTURE
#define _HDR_TEXTURE

#include <glew/glew.h>
#include <ctime>

//Texture library
//Including light bmp loader (windows 24bit/px only)

typedef struct{
    unsigned char R;
    unsigned char G;
    unsigned char B;
} RGBcolor;
RGBcolor useRGB(unsigned char,unsigned char,unsigned char);

class texture{
    private:
        GLuint texture_data;

        unsigned int width;
        unsigned int height;

        static texture* current;

    public:
        //texture();
        texture(GLuint,unsigned int,unsigned int);
        ~texture();

        unsigned int getWidth();
        unsigned int getHeight();
        GLuint texData();

        static void bind(texture*);
        static texture* texFromBMP(char*,RGBcolor* =NULL);

        static unsigned int getCurWidth();
        static unsigned int getCurHeight();

};

class animated_texture{
    private:
        unsigned short frame_number;
        GLuint* texture_data;
        unsigned short* delays;
        unsigned int width;
        unsigned int height;

    public:
        //animated_texture();
        animated_texture(unsigned short,unsigned int,unsigned int);
        ~animated_texture();

        unsigned int getWidth();
        unsigned int getHeight();
        unsigned short getFrNum();
        GLuint*  lptexData(unsigned short=0);
        GLuint  texData(unsigned short);
        unsigned short* lpdelay(unsigned short=0);
        unsigned short delay(unsigned short);

        static void bind(animated_texture*,unsigned short);
        static animated_texture* texFromANM(char*,RGBcolor* = NULL);
};

class motion_controller{

    private:
        animated_texture*   support;
        int                 lastframe;
        clock_t             framestart;
        bool                backlooping;

    public:
        bool                backloop;
        clock_t             loop_delay;
        float               speed;

        motion_controller(animated_texture* =NULL);

        void bind();
        void zero();

};

#endif
